package org.example.graph;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 顶点
 */

public class Vertex {
    String name;
    public Boolean visited = false; //是否访问：用于BFS DFS
    public int status = 0;          //状态 0-未访问 1-访问中 2-访问结束 用于拓扑排序
    public List<Edge> edges;
    public int inDegree = 0;    //入度用于拓扑排序

    public int dist = INF;      //距离
    static final Integer INF = Integer.MAX_VALUE;
    public ArrayList<String> path = new ArrayList<>();  //路径

    public Vertex(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static void main(String[] args) {
        Vertex a = new Vertex("A");
        Vertex b = new Vertex("B");
        Vertex c = new Vertex("C");
        Vertex d = new Vertex("D");

        a.edges = List.of(new Edge(b),new Edge(c));
        b.edges = List.of(new Edge(d));
        c.edges = List.of(new Edge(d));


    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Vertex vertex = (Vertex) o;
        return Objects.equals(name, vertex.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
